﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Entity;
using System.Text;
using DTO;


namespace DAL
{
    public class CollectorService
    {
        CRMEntities db;
        public List<CollectorEntity> LoadCollectorbyAll()
        {
            db = new CRMEntities();
            var query = (from co in db.Collectors
                        select new CollectorEntity 
                        {
                            Collector_ID = co.ID,
                            Collector_Code = co.Collector_Code,
                            FullName = co.FullName,
                            Region_ID = co.Region_ID,
                        }).ToList();
            return query;
        }

        public CollectorEntity LoadCollectorByID(int collectorid)
        {
            db = new CRMEntities();
            var query = (from co in db.Collectors
                         select new CollectorEntity
                         {
                             Collector_ID = co.ID,
                             Collector_Code = co.Collector_Code,
                             FullName = co.FullName,
                             Region_ID = co.Region_ID,
                         }).SingleOrDefault();
            return query;
        }


    }
}
